<%@ page language="java" import="java.util.*,com.knife.member.*,java.text.SimpleDateFormat,java.sql.Timestamp" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
String msg="";

int	uid				= Integer.parseInt(request.getParameter("uid"));
String acount		= request.getParameter("acount");
String oldpassword 	= request.getParameter("oldpassword");
String newpassword 	= request.getParameter("newpassword");

if(uid>0){
	UserinfoDAO userDAO = new UserinfoDAO();
	Userinfo newUser = userDAO.findById((long)uid);
	if(CheckPassword.validatePassword(newUser.getPassword(), oldpassword)){
	//if(oldpassword.equals(newUser.getPassword())){
		if(newUser.getAcount().equals(acount)){
			newpassword=CheckPassword.generatePassword(newpassword);
			newUser.setPassword(newpassword);
			try{
				userDAO.save(newUser);
				msg="修改成功！";
			}catch(Exception e){
				msg="修改失败！";
			}
		}else{
			msg="卡号不正确！";
		}
	}else{
		msg="密码不正确！";
	}

}
%>
<script language="javascript">
alert("<%=msg%>");
history.back(-1);
</script>